package org.example.controller;

import org.example.mapper.TestMapper;
import org.example.model.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/test")
public class TestController {

    @Autowired
    private TestMapper testMapper;


    @RequestMapping("/insertSelective")
    public Object insertSelective(Test test){
        int n = testMapper.insertSelective(test);
        return null;
    }

    @RequestMapping("/updateSelective")
    public Object updateSelective(Test test){
        int n = testMapper.updateSelective(test);
        return null;
    }

    @RequestMapping("/selectSelective")
    public Object selectSelective(Test test){
        List<Test> tests = testMapper.selectSelective(test);
        return tests;
    }

    @RequestMapping("/deleteByIds")
    //前端传入的数据id=1&id=2&id=3，不能传ids=[1,2,3]
    public Object deleteByIds(@RequestParam("id") List<Integer> ids){
        int n = testMapper.deleteByIds(ids);
        return null;
    }

    //传入list，使用json比较方便
    @RequestMapping("/insertBatch")
    public Object insertBatch(@RequestBody List<Test> test){
        int n = testMapper.insertBatch(test);
        return null;
    }










}
